package server.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import server.model.entity.Shop;
import server.model.entity.ShopOrder;
import server.model.entity.ShopOrderItem;
import server.model.entity.Users;

import java.util.List;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
public interface ShopOrderItemDao extends JpaRepository<ShopOrderItem, String> {
    List<ShopOrderItem> findByShopOrder_Users(Users users);
    List<ShopOrderItem> findByShopOrderId(String orderId);
    @Modifying
    @Query(value = "select * from Shop_Order_Item where order_Id in (select id from shop_order" +
            " where user_id in (:userIds) )", nativeQuery = true)
    List<ShopOrderItem> findByShopOrder_Users_IdIn(@Param("userIds") List<String> userIds);
}
